<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加角色</title>
<link rel="stylesheet" 
		href="${pageContext.request.contextPath}/themes/icon.css">
<link rel="stylesheet" 
		href="${pageContext.request.contextPath}/themes/bootstrap/easyui.css">
<script type="text/javascript" 
		src="${pageContext.request.contextPath}/js/jquery.js"></script>
<script type="text/javascript" 
		src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript" 
		src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
</head>

<body>
<div id="role">
	<form id="addRole" method="post" style="margin-left: 100px;margin-top: 100px;">   
		    <div>   
		        <label for="name">角色名称:</label>   
		       <input class="easyui-textbox"  name="name" style="width:200px,height:40px;">   
		    </div> 
		    <div>
		    	<label>选择功能:</label>
		    	<input id="Roles" name="role" value="01">  
		    </div>  
		    <a id="btn" href="#">提交</a>
		</form>	
</div>

<table id="role1"></table> 
	<script type="text/javascript">
	$(function () {
		$('#role').window({    
		    width:600,    
		    height:400,    
		    modal:true   
		});
		$('#role').window("close");
		$('#btn').linkbutton({    
		    iconCls: 'icon-ok'   
		}); 
		$('#cancel').linkbutton({    
		    iconCls: 'icon-cancel'   
		});
		 
		
		$('#role1').datagrid({    
		    url:'selectRoles',
		    pagination:true,
		    rownumbers:true,
		    columns:[[   
		    	{field:'ck',checkbox:true,width:100},
		        {field:'roleId',title:'角色Id',hidden:true,width:100},    
		        {field:'roleName',title:'角色名',width:100},    
		        {field:'fids',title:'功能列表',width:100},       
		    ]] ,
		    toolbar: [{
				iconCls: 'icon-add',
				text:'添加',
				handler: function(){
					$('#Roles').combotree({ 
						width:160,
						onlyLeafCheck:true,
						multiple:true,
					    url: 'showRole1',    
					    required: true ,
						onBeforeExpand:function(node){
							if (node.children.length>0) {
								return true;
							}else {
								return false;
							}
						}  
					});
					 $('#role').window('open');
					 
					}
			}]

		    
		}); 
		$('#addRole').form({    
	        url:'addRole1',    
	        success:function(data){ 
	        	
	              if(data=='true'){
	            	  $('#role').window('close');  
	            	  $('#addRole').form('clear');
						 $('#role1').datagrid('reload');
	              } else {
	            	  $.messager.alert("消息提示","添加失败");
				}
	        }    
		}); 
	    $('#btn').bind('click', function(){
	    	$('#addRole').submit();
	    	
	    }); 
	    $('#cancel').bind('click', function(){    
	    	$('#role').window('close');
			$('#addRole').form('clear');
	    }); 
		 
	})
</script>
</body>
</html>